package com.example.hy2110szyx.service.impl;

import com.example.hy2110szyx.entity.Customer;
import com.example.hy2110szyx.repository.CustomerMapper;
import com.example.hy2110szyx.service.CustomerService;
import com.example.hy2110szyx.vo.PageVo;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomerServiceImpl implements CustomerService {

    @Autowired
    private CustomerMapper customerMapper;

    @Override
    public Customer queryByIdentity(String identity) {
        return customerMapper.queryByIdentity(identity);
    }

    @Override
    public List<Customer> queryAll() {
        return customerMapper.queryAll();
    }

    @Override
    public Customer queryByCno(String cno) {
        return customerMapper.queryByCno(cno);
    }


    @Override
    public Customer queryByPhone(String phone) {
        return null;
    }

    /**
     * 根据条件分页查询所有旅客信息
     * @param pageVo
     * @return
     */
    @Override
    public Page<Customer> queryAllCustomersForPage(PageVo<Customer> pageVo) {
        Page<Customer> page = PageHelper.startPage(pageVo.getStart(), pageVo.getMax(),
                pageVo.getOrderBy() + " " + pageVo.getOrder());
        customerMapper.queryAllCustomersConn(pageVo.getCondition());
        return page;
    }

    @Override
    public void deleteSomeById(Integer[] ids) {
        customerMapper.deleteSomeById(ids);
    }
    @Override
    public void insertCustomer(Customer customer) {
        customerMapper.insertCustomer(customer);
    }

    @Override
    public void updateOneCustomer(Customer customer) {
        customerMapper.updateOneCustomer(customer);
    }


}
